package hxy.bytecode.json;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import hxy.bytecode.entity.DefaultIssue;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author eric
 * @program bytecode
 * @description
 * @date 2020/7/9
 */
public class FastjsonTest {

    public static void main(String[] args) {
        List<String> a = new ArrayList<>();
        a.add("好的");
        a.add("aaa");
        List<DefaultIssue> defaultIssues = new ArrayList<>();

        DefaultIssue defaultIssue = new DefaultIssue();
        defaultIssue.setFlows("1");
        defaultIssue.setComponent("222");
        defaultIssue.setProject("eeeeeee");
        DefaultIssue defaultIssue1 = new DefaultIssue();
        defaultIssue1.setFlows("1");
        defaultIssue1.setComponent("222");
        defaultIssue1.setProject("eeeeeee");

        defaultIssues.add(defaultIssue);
        defaultIssues.add(defaultIssue1);
        String s = JSONObject.toJSONString(defaultIssues);
        System.out.println(s);

        Map<String, Object> response = new HashMap<>();
        response.put("data",defaultIssues);
        String sresponse = JSONObject.toJSONString(response);
        System.out.println(sresponse);

        List<DefaultIssue> oldk = JSONArray.parseArray(s,DefaultIssue.class);
        System.out.println(oldk.size());
        List<DefaultIssue> list = JSONObject.parseObject(s, List.class);
        System.out.println(list.size());
    }
}


